<template>
	<view>
		<u-navbar title="反馈" backIconColor="#fff" titleColor="#fff" :background="background"></u-navbar>
		<view class="home">
			<view class="u-p-t-20 u-p-b-20"><u-alert-tips @close="close" :show="show" :closeAble="closeAble" :showIcon="true" icon="file-text" class="desctip" type="info" description="您的意见或者建议就是我们前进的动力~~~"></u-alert-tips></view>
			<u-gap bgColor="#f7f7f7" height="2"></u-gap>
			<u-form :model="form" ref="uForm">
				<u-form-item><u-input type="textarea" v-model="form.suggestion" placeholder="请输入您的意见或者建议"/></u-form-item>
				<u-form-item><u-input v-model="form.tel" placeholder="请输入您的联系方式"/></u-form-item>
			</u-form>
			<u-button @click="submit()" class="button">提交</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				background: {
					'background-image': 'linear-gradient(45deg, #2BC3C8, #84E7B9)'
				},
				closeAble:true,
				show:true,
				form: {
					tel: '',
					suggestion: ''
				}
			}
		},
		onLoad() {
		},
		methods: {
			// 提交
			submit(){
			if (this.form.suggestion=="") {
					this.$u.toast('总得提交点啥吧...');
					return;
				}
				if (this.form.tel=="") {
					this.$u.toast('总得告诉我你的联系方式吧...');
					return;
				}
				uni.request({
				 	url:"http://192.168.137.139:8080/doFeedback",
					method:"POST",
					data:this.form,
					success: (res) => {
					 if (res.data.code*1==200) {
						 try{
							console.log("页面跳转")
							console.log(res)
							this.$u.toast('感谢反馈...');
							// 延迟弹窗
							setTimeout(function(){
								uni.navigateBack()
							},1000);
							
						 }catch(e){
							 this.$u.toast('身份信息格式异常')
							console.log(res)
						 }
					 } else{
						this.$u.toast('用户名或者密码错误')
					 }
					}
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.button{
		background-image: linear-gradient(45deg, #2BC3C8, #84E7B9);
		margin-top: 60rpx;
		color: #FFFFFF;
	}
	.desctip{
		letter-spacing: 2rpx;
	}
</style>
